package zju.ccnt.config;

import org.apache.tomcat.jdbc.pool.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import zju.ccnt.rest.service.util.sql.JdbcViewUtil;
import zju.ccnt.rest.service.util.sql.ViewUtil;

import javax.validation.Validation;
import javax.validation.Validator;

/**
 * Created by zha on 14/11/6.
 */
@Configuration
public class BeanConfig {

    @Bean
    public Validator validator(){
        return Validation.buildDefaultValidatorFactory().getValidator();
    }

    @Bean
    @Autowired
    public ViewUtil jdbcSqlUtil(@Qualifier("sqlDataSource")DataSource dataSource) {
        return new JdbcViewUtil(dataSource);
    }

}
